<template>
  <div class="demo">
    <h2>学校名称:{{ schoolName }}</h2>
    <h2>学校地址:{{ address }}</h2>
  </div>
</template>

<script>
import pubsub from "pubsub-js";
export default {
  name: "MySchool",

  data() {
    return {
      schoolName: "尚硅谷",
      address: "北京",
    };
  },
  mounted() {
    // console.log("MySchool", this.x);
    // this.$bus.$on("hello", (data) => {
    //   console.log("MySchool收到了数据", data);
    // });
    const pubId = pubsub.subscribe("hello", function (msgName, data) {
      console.log("有人发布了hello消息", msgName, data);
    });
  },
  beforeDestroy() {
    // this.$bus.$off("hello");
    pubsub.unsubseribe;
  },
};
</script>
<style scoped>
.demo {
  background-color: skyblue;
}
</style>
